<?php
/**
 * Copyright (c) 不争网络
 *
 * @Description     需要登录基础框架.
 * @Author          zhangyong QQ:2315918189
 * @Copyright       Copyright (c) 不争网络 保留所有版权()
 * @Date:           2018/7/19 0019
 * @CreateBy        PhpStorm.
 */
namespace app\common\controller;
class CommonApi extends Base{
    public function _initialize(){
        parent::_initialize();
        $token = input('token','','trim');
        if($token === ''){
            $this->apiReturn(0,'非法访问');
        }
        $Aes = new \Aes\Aes();
        $token = $Aes->aes128cbcHexDecrypt($token);
        $info = db('User')->where('token',$token)->find();
        if(empty($info)){
            $this->apiReturn(0,'用户不合法,无权访问');
        }
        define('UID',$info['id']);
    }
}